#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <windows.h>
#include "luthor.h"
using namespace LuaWanbHash;
using namespace std;

#define OP LT::op()
#define CL cl()
//Var LT::STbl::Tnode::nil=ltMV(NotFound());


int main (int argc, char **argv) {
  int matches=0;
  if (argc<3) {
     cout << "luthorgrep pattern filename\n";
     return 0;
  }
  string ln;
  Luthor pat(argv[1]);
  //Luthor pat=Luthor("[^\\a]Tom[^\\a]").add("[^\\a]Sawyer[^\\a]").add("[^\\a]Huckleberry[^\\a]").add("[^\\a]Finn[^\\a]");
  //Luthor pat=Luthor("[^\\a]([Tt]om|[Hh]uck)[^\\a].*?[Bb]ecky").add("[Bb]ecky.*?[^\\a]([Tt]om|[Hh]uck)[^\\a]");
  ifstream in(argv[2]);
  Tbl res;
  int st,nd;
  st=GetTickCount();
  while (!getline(in,ln).eof()) {
    if (pat.find(ln)->len()) {
       cout << ln <<"\n";
       matches++;
    }
  }
  nd=GetTickCount();
  cout <<"time="<<nd-st<<"  "<<matches<<" matches\n";
}
